package Operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

/**
 * Description:
 * Date: 2025-10-18
 * Time: 18:56
 */
public class FindBook implements IOperation{
    public void work(BookList bookList) {
        System.out.println("查找图书！！！");

        System.out.print("请输入你要查找的图书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        for (int i = 0; i < bookList.getCurrentSize(); i++) {
            Book book = bookList.getBooks(i);
            boolean flg = book.getName().equals(name);
            if(flg == true){
                System.out.println("找到了!");
                System.out.println(bookList.getBooks(i));
                return;
            }
        }
        System.out.println("没有找到你所要的图书！");
    }
}
